﻿@using Maxi.Models;
@using Maxi.Models.Banco;
@model  Maxi.Areas.Sistema.Models.ProfessorModel
@{
    List<Maxi.Models.Banco.Tb_Grupo> grupos = new List<Maxi.Models.Banco.Tb_Grupo>();

    grupos = ViewBag.Grupos;
}
<div class="row">
    <div class="col-md-12">
        <div class="portlet box blue-hoki ">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-gift">
                    </i>
                    Professor
                </div>
            </div>
            <div class="portlet-body form">
                <form id="formProf" action="@Url.Content("~/salvarprofessor")" method="post" class="form-horizontal" role="form">
                    <div class="form-body">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Código
                                    </label>
                                    <div class="col-md-6">
                                        <input name="codigo" type="text" class="form-control" value="@Model.codigo" placeholder="Código">
                                    </div>
                                </div>
                            </div>
                        </div>
                        @{
                            if (Model.usuario != null)
                            {
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="form-group">
                                            <label class="control-label col-md-3">
                                                Usuário
                                            </label>
                                            <div class="col-md-6">
                                                <input type="text" class="form-control" value="@Model.usuario" placeholder="Usuário" disabled="disabled" />
                                                <input type="hidden" name="usuario" value="@Model.usuario" />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            }
                        }
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Nome
                                    </label>
                                    <div class="col-md-6">
                                        <input name="nome" type="text" class="form-control" value="@Model.nome" placeholder="Nome">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Grupo de Permissões
                                    </label>
                                    <div class="col-md-6">
                                        <select name="grupo" class="form-control">
                                            <option value="">Selecione...</option>
                                            @{
                                                foreach (Tb_Grupo item in grupos)
                                                {
                                                    if (item.Id == Model.grupo.ToInt32())
                                                    {
                                                        <option selected value="@item.Id">@item.Nome</option>
                                                    }
                                                    else
                                                    {
                                                        <option value="@item.Id">@item.Nome</option>
                                                    }
                                                }
                                            }
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        E-mail
                                    </label>
                                    <div class="col-md-6">
                                        <input name="email" type="text" class="form-control" value="@Model.email" placeholder="E-mail">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        DDD
                                    </label>
                                    <div class="col-md-6">
                                        <input name="ddd" type="text" class="form-control" value="@Model.ddd" placeholder="DDD">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Telefone
                                    </label>
                                    <div class="col-md-6">
                                        <input name="telefone" type="text" class="form-control" value="@Model.telefone" placeholder="Telefone">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        CEP
                                    </label>
                                    <div class="col-md-6">
                                        <input name="cep" type="text" class="form-control" value="@Model.cep" placeholder="CEP">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Endereço
                                    </label>
                                    <div class="col-md-6">
                                        <input name="endereco" type="text" class="form-control" value="@Model.endereco" placeholder="Endereço">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Bairro
                                    </label>
                                    <div class="col-md-6">
                                        <input name="bairro" type="text" class="form-control" value="@Model.bairro" placeholder="Bairro">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Cidade
                                    </label>
                                    <div class="col-md-6">
                                        <input name="cidade" type="text" class="form-control" value="@Model.cidade" placeholder="Cidade">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        UF
                                    </label>
                                    <div class="col-md-6">
                                        <input name="uf" type="text" class="form-control" value="@Model.uf" placeholder="UF">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        RG
                                    </label>
                                    <div class="col-md-6">
                                        <input name="rg" type="text" class="form-control" value="@Model.rg" placeholder="RG">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Orgão Expedidor 
                                    </label>
                                    <div class="col-md-6">
                                        <input name="rgorgexp" type="text" class="form-control" value="@Model.rgorgexp" placeholder="Orgão Expedidor ">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Data Expedição RG
                                    </label>
                                    <div class="col-md-6">
                                        <input name="rgdata" type="text" class="form-control" value="@Model.rgdata" placeholder="Data Expedição RG">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Apelido
                                    </label>
                                    <div class="col-md-6">
                                        <input name="apelido" type="text" class="form-control" value="@Model.apelido" placeholder="Apelido">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                <button type="submit" class="btn green">
                                    Enviar
                                </button>
                                <a href="@Url.Content("~/alunos")" class="btn default">
                                    Cancelar
                                </a>
                            </div>
                        </div>
                    </div>
                    @Html.AntiForgeryToken()
                </form>
            </div>
        </div>

    </div>
</div>
@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $('.date-picker').datepicker({
                rtl: Metronic.isRTL(),
                orientation: "left",
                autoclose: true,
                language: 'pt-br',
                format: 'dd/mm/yyyy'
            });

            var rules = {
                codigo: {
                    required: true,
                    maxlength: 13
                },
                nome: {
                    required: true,
                    maxlength: 60
                },
                grupo: {
                    required: true
                },
                email: {
                    email: true,
                    required: true,
                    maxlength: 40
                },
                ddd: {
                    required: true,
                    maxlength: 2
                },
                telefone: {
                    required: true,
                    maxlength: 26
                },
                cep: {
                    required: true,
                    maxlength: 9
                },
                endereco: {
                    required: true,
                    maxlength: 89
                },
                bairro: {
                    required: true,
                    maxlength: 40
                },
                cidade: {
                    required: true,
                    maxlength: 35
                },
                uf: {
                    required: true,
                    maxlength: 2
                },
                rg: {
                    required: true,
                    maxlength: 15
                },
                rgorgexp: {
                    required: true,
                    maxlength: 10
                },
                rgdata: {
                    required: true
                },
                apelido: {
                    maxlength: 15
                }
            };

            var obrigatorio = "Campo obrigatório";

            var messages = {
                codigo: {
                    required: obrigatorio,
                    minlength: "Máximo de 13 caracteres"
                },
                grupo: {
                    required: "Selecione um grupo"
                },
                nome: {
                    required: obrigatorio,
                },
                email: {
                    email: "Digite um e-mail válido",
                    required: obrigatorio,
                    maxlength: "Máximo de 40 caracteres"
                },
                ddd: {
                    required: obrigatorio,
                    maxlength: "Máximo de 2 caracteres"
                },
                telefone: {
                    required: obrigatorio,
                    maxlength: "Máximo de 26 caracteres"
                },
                cep: {
                    required: obrigatorio,
                    maxlength: "Máximo de 9 caracteres"
                },
                ddd: {
                    required: obrigatorio,
                    maxlength: "Máximo de 9 caracteres"
                },
                endereco: {
                    required: obrigatorio,
                    maxlength: "Máximo de 89 caracteres"
                },
                bairro: {
                    required: obrigatorio,
                    maxlength: "Máximo de 40 caracteres"
                },
                cidade: {
                    required: obrigatorio,
                    maxlength: "Máximo de 35 caracteres"
                },
                uf: {
                    required: obrigatorio,
                    maxlength: "Máximo de 2 caracteres"
                },
                rg: {
                    required: obrigatorio,
                    maxlength: "Máximo de 15 caracteres"
                },
                rgorgexp: {
                    required: true,
                    maxlength: "Máximo de 10 caracteres"
                },
                rgdata: {
                    required: obrigatorio
                },
                apelido: {
                    maxlength: "Máximo de 15 caracteres"
                }
            };
            $("#formProf").validateform("Espaços", "/Espacos", rules, messages);
        });
    </script>
}